package com.rbcs.reimb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.rbcs.base.model.Currency;
import com.rbcs.base.model.Item;
import com.systop.core.model.BaseModel;

/***
 * 报销明细表
 * @author ShangHua
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "reimb_details")
public class ReimbDetail extends BaseModel {
  //ID
	private Integer id;

  //报销标摘要
	private String title;
	
	//报销金额
	private Double amount;
	
	//报销外币金额
	private Double exchangeAmount;

	//预算科目
	private Item item;

  //报销申请主表
	private Reimb reimb;
	
	private Currency currency;

	//报销总金额
	private Double totalAmount;
	
	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(precision = 10, scale = 2)
	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
	@Column(name="exchange_amount", precision = 10, scale = 2)
  public Double getExchangeAmount() {
		return exchangeAmount;
	}

	public void setExchangeAmount(Double exchangeAmount) {
		this.exchangeAmount = exchangeAmount;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "item_id")
	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "reimb_id")
  	public Reimb getReimb() {
		return reimb;
	}

	public void setReimb(Reimb reimb) {
		this.reimb = reimb;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "currency_id")
	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	@Transient
	public Double getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Double totalAmount) {
		this.totalAmount = totalAmount;
	}

}
